package com.group.activity.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lins
 * @date 2021/11/15 20:56
 */
@Configuration
public class MyMqConfig {
    @Bean
    public Binding orderDelayExchangeRelationship() {
        return new Binding(
                "order.delay.queue",
                Binding.DestinationType.QUEUE,
                "order-event-exchange",
                "order.create.order",
                null
        );
    }
    @Bean
    public Queue orderDelayQueue(){
        Map<String, Object> arguments = new HashMap<>();
        arguments.put("x-dead-letter-exchange", "order-event-exchange");
        arguments.put("x-dead-letter-routing-key", "order.release.order");
        arguments.put("x-message-ttl", 60000);
        return new Queue(
                "order.delay.queue",
                true,
                false,
                false,
                arguments);
    }
    @Bean
    public Queue seckillCreateOrderQueue(){
        return new Queue(
                "seckill.create.order.queue",
                true,
                false,
                false
        );
    }
    @Bean
    public Binding seckillCreateOrderBinding(){
        return new Binding(
                "seckill.create.order.queue",
                Binding.DestinationType.QUEUE,
                "order-event-exchange",
                "order.seckill.create",
                null
        );
    }
}
